<?php
class CommonCharging
{
    public function buildLinkChargingUser($data)
    {
        $info = "";
        foreach($data as $key=>$value){
            $info .= "&" . $key . "=" . base64_encode($value);
        }
        
        $info = ltrim($info, "&");
        $info = urlencode(base64_encode($info));
        
        $url = Url::createUrl("/charging/user") . "?info=" . $info;
 
        return $url;
    }
    
    public function buildLinkCharging($data)
    {
        $info = "";
        foreach($data as $key=>$value){
            $info .= "&" . $key . "=" . base64_encode($value);
        }
        $info = ltrim($info, "&");
        $info = urlencode(base64_encode($info));
        
        $url = Url::createUrl("/charging/index") . "?info=" . $info;
 
        return $url;
    }
    
    public function buildLinkChargingPacket($data)
    {
        $info = "";
        foreach($data as $key=>$value){
            $info .= "&" . $key . "=" . base64_encode($value);
        }
        $info = ltrim($info, "&");
        $info = urlencode(base64_encode($info));
         
        $link_charging = Url::createUrl("/charging/packet");
           
        if(!empty($_SESSION["msisdn"])){
            $url = $link_charging . "?info=" . $info . "&msisdn=" . $_SESSION["msisdn"];
        } else {
            $url = "http://" . $_SERVER["SERVER_NAME"] . $link_charging . "?info=" . $info;
            $url = "http://myzone.vn?url_detect=" . urlencode($url);
        }
        
        return $url;
    }   
}  
?>
